# 7.编写 Person 类和Teacher 类
# 要求：Person 类，其具有 name、age、sex 等属性。继承于 Person 类的 Teacher 类，
# 具 有 title、quality、salary、prize 等属性。显示这些属性，并计算 salary、prize 之和。
class Person:
    def __init__(self,name,age,sex):
        self.name=name
        self.age=age
        self.sex=sex

    def print(self):
        print(f"name:{self.name},age:{self.age},sex:{self.sex}")

class Teacher(Person):
    def __init__(self,person,title,quality,salary,prize):
        self.name=person.name
        self.age=person.age
        self.sex=person.sex
        self.title=title
        self.quality=quality
        self.salary=salary
        self.prize=prize

    def print(self):  # 同名函数会继承父类的执行语句并且加上子类独有的语句
        super().print()
        print(f"title:{self.title},quality:{self.quality},salary:{str(self.salary)},prize:{str(self.prize)}")

    def sum(self):
        return self.salary + self.prize
person=Person("周杰伦",18,"男")
teacher=Teacher(person,"教授","good",20000,2000)
teacher.print()
print("sum:",teacher.sum())

